package com.bw.study;

import android.os.Bundle;
import android.view.LayoutInflater;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;

import com.bw.study.databinding.ActivityRvBinding;

import java.util.ArrayList;
import java.util.List;

public class RvActivity extends AppCompatActivity {

    private List<String>list=new ArrayList<>();
    private ActivityRvBinding rvBinding;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        rvBinding = ActivityRvBinding.inflate(LayoutInflater.from(this));
        setContentView(rvBinding.getRoot());
        initData();
        LinearLayoutManager manager = new LinearLayoutManager(this);
        manager.setOrientation(LinearLayoutManager.VERTICAL);
        rvBinding.rv.setLayoutManager(manager);
        rvBinding.rv.setAdapter(new RvAdapter(list));
    }

    private void initData(){
        for (int i = 0;i < 20; i++){
            list.add("item:"+i);
        }
    }

}
